public class Work11 {
    public static void main(String[] args) {
        int i;
        for(i=1000;i<10000;i++){
            int a = i%10;
            int b = (i/10)%10;
            int c = (i/100)%10;
            int d = i/1000;
            if(i==a*a*a*a+b*b*b*b+c*c*c*c+d*d*d*d){
                System.out.println(i);
            }
        }
        System.out.println();
    }
}

